package com.neuedu.controller;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.neuedu.entity.UserAnswer;
import com.neuedu.entity.UserAnswerItem;
import com.neuedu.service.UserAnswerItemService;
import com.neuedu.service.UserAnswerService;
import com.neuedu.vo.ResultJson;
import jakarta.annotation.Resource;
import org.mockito.stubbing.Answer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 用户答题统计表 前端控制器
 * </p>
 *
 * @author wangyu
 * @since 2025-09-17
 */
@RestController
@RequestMapping("/userAnswer")
public class UserAnswerController {
    @Resource
    UserAnswerService userAnswerService;
    @Resource
    UserAnswerItemService userAnswerItemService;
    @PostMapping("/save")
    public ResultJson<Boolean> save(String content, Long login_id) {
        return ResultJson.success(userAnswerService.save(content, login_id), "保存成功");
    }

    @GetMapping("/getAnwser")
    ResultJson<List<UserAnswer>> getAnwser(Long login_id) {
        return ResultJson.success(userAnswerService.getAnswer(login_id));
    }
    @GetMapping("/getItems")
    ResultJson<List<UserAnswerItem>> getItems(Long answerId) {
        return ResultJson.success(userAnswerItemService.list(answerId));
    }
    @GetMapping("/getAnwserByUserId")
    ResultJson<List<UserAnswer>> getAnwserByUserId(Long userId) {
        return ResultJson.success(userAnswerService.getAnswer(userId));
    }

}
